package Simulator;

import Shared.MapPosition;

/**
 * The AmbulanceGenerator module, see Architecture report for specifications.
 */

public class EmergencyGenerator {

	private EnvironmentDatabase db;

	private static EmergencyGenerator singleton = new EmergencyGenerator();

	/**
	 * @return the unique RadioSoftware instance.
	 */
	public static EmergencyGenerator getInstance() {
		return singleton;
	}

	private EmergencyGenerator() {
		this.db = EnvironmentDatabase.getInstance();
	}

	/**
	 * Create an emergency (randomly urgent or not) and put it in the
	 * environment database.
	 * 
	 * @param pos
	 *            the emergency position.
	 */
	public void addERFromPosition(MapPosition pos) {
		if (Math.random() > 0.5)
			this.addERFromPosition(pos, true);
		else
			this.addERFromPosition(pos, false);
	}

	/**
	 * Create an emergency of type urgnet or not and put it in the environment
	 * database.
	 * 
	 * @param pos
	 *            the emergency position.
	 * @param type
	 *            true if urgent, false otherwise.
	 */
	public void addERFromPosition(MapPosition pos, boolean type) {

		this.db.addER(new ER("John Doe", "0123456789", pos, type, pos, "An urgent emergency"));

	}
}
